Option Explicit On Option Strict On Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox Friend WithEvents TxtMiddleMean As System.Windows.Forms.TextBox Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents TxtCurve As System.Windows.Forms.TextBox Friend WithEvents Label3 As System.Windows.Forms.Label Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox Friend WithEvents LstStudents As System.Windows.Forms.ListBox Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.GroupBox1 = New System.Windows.Forms.GroupBox Me.TxtMiddleMean = New System.Windows.Forms.TextBox Me.Label2 = New System.Windows.Forms.Label Me.TxtCurve = New System.Windows.Forms.TextBox Me.Label3 = New System.Windows.Forms.Label Me.GroupBox2 = New System.Windows.Forms.GroupBox Me.LstStudents = New System.Windows.Forms.ListBox Me.GroupBox1.SuspendLayout() Me.GroupBox2.SuspendLayout() Me.SuspendLayout() ' 'Label1 ' Me.Label1.AutoSize = True Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 18.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.Location = New System.Drawing.Point(136, 40) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(392, 37) Me.Label1.TabIndex = 0 Me.Label1.Text = "Dr Test's Midterm Analysis" ' 'GroupBox1 ' Me.GroupBox1.Controls.Add(Me.TxtCurve) Me.GroupBox1.Controls.Add(Me.Label3) Me.GroupBox1.Controls.Add(Me.TxtMiddleMean) Me.GroupBox1.Controls.Add(Me.Label2) Me.GroupBox1.Location = New System.Drawing.Point(32, 104) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size(352, 160) Me.GroupBox1.TabIndex = 3 Me.GroupBox1.TabStop = False Me.GroupBox1.Text = "Summary" ' 'TxtMiddleMean ' Me.TxtMiddleMean.Location = New System.Drawing.Point(160, 40) Me.TxtMiddleMean.Name = "TxtMiddleMean" Me.TxtMiddleMean.ReadOnly = True Me.TxtMiddleMean.Size = New System.Drawing.Size(96, 22) Me.TxtMiddleMean.TabIndex = 4 Me.TxtMiddleMean.Text = "" ' 'Label2 ' Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.2!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label2.Location = New System.Drawing.Point(32, 40) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(120, 40) Me.Label2.TabIndex = 3 Me.Label2.Text = "Middle Mean" ' 'TxtCurve ' Me.TxtCurve.Location = New System.Drawing.Point(160, 96) Me.TxtCurve.Name = "TxtCurve" Me.TxtCurve.ReadOnly = True Me.TxtCurve.Size = New System.Drawing.Size(96, 22) Me.TxtCurve.TabIndex = 6 Me.TxtCurve.Text = "" ' 'Label3 ' Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.2!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label3.Location = New System.Drawing.Point(32, 96) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(120, 40) Me.Label3.TabIndex = 5 Me.Label3.Text = "Curve" ' 'GroupBox2 ' Me.GroupBox2.Controls.Add(Me.LstStudents) Me.GroupBox2.Location = New System.Drawing.Point(32, 296) Me.GroupBox2.Name = "GroupBox2" Me.GroupBox2.Size = New System.Drawing.Size(352, 248) Me.GroupBox2.TabIndex = 4 Me.GroupBox2.TabStop = False Me.GroupBox2.Text = "Student Results (curved)" ' 'LstStudents ' Me.LstStudents.ItemHeight = 16 Me.LstStudents.Location = New System.Drawing.Point(24, 32) Me.LstStudents.Name = "LstStudents" Me.LstStudents.Size = New System.Drawing.Size(312, 196) Me.LstStudents.TabIndex = 0 ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15) Me.ClientSize = New System.Drawing.Size(760, 568) Me.Controls.Add(Me.GroupBox2) Me.Controls.Add(Me.GroupBox1) Me.Controls.Add(Me.Label1) Me.Name = "Form1" Me.Text = "Form1" Me.GroupBox1.ResumeLayout(False) Me.GroupBox2.ResumeLayout(False) Me.ResumeLayout(False) End Sub #End Region Dim scores(100) As Double Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim inpf As IO.StreamReader Dim std As Integer = 0 Dim currLine As String Dim max As Double = 0 Dim min As Double = 100 Dim sum As Double = 0 Dim middleMean As Double Dim curve As Double Dim cnt As Integer Dim outString As String If IO.File.Exists("scores.txt") Then ' read student scores out of file into array inpf = IO.File.OpenText("scores.txt") Do Until inpf.Peek = -1 currLine = inpf.ReadLine() ' if appropriat einput add to the array and prepare to go to next element If IsNumeric(currLine) Then scores(std) = Convert.ToDouble(currLine) ' check for new high or low If scores(std) > max Then max = scores(std) End If If scores(std) < min Then min = scores(std) End If sum = sum + scores(std) ' prepare for next student std = std + 1 End If Loop middleMean = (sum - (max + min)) / (std - 2) TxtMiddleMean.Text = middleMean.ToString("n2") If middleMean < 80 Then curve = 80 - middleMean Else curve = 0 End If TxtCurve.Text = curve.ToString("n2") ' loop back and add curve to every student For cnt = 0 To std - 1 outString = (cnt + 1).ToString("n0") & " " outString = outString & scores(cnt).ToString("n2") & " " scores(cnt) = scores(cnt) + curve outString = outString & " ==> " & scores(cnt).ToString("n2") & " " If scores(cnt) >= 92.0 Then outString = outString & " A" End If LstStudents.Items.Add(outString) Next cnt End If End Sub End Class